package com.aop;


import china.MakerApplication;
import com.zhouyu.Tom;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;




@Aspect
//@Component
@Async
public class HelloWorldAop {



	@Bean("goood")
	public HelloWorldAop goood(){
		return new HelloWorldAop();
	}

	static {
		System.out.println("++++++++++++");
	}

	@Pointcut("execution(* com.zhouyu.Tom.helloWorld())")
	public void aaa(){}

//	@Before("execution(  String  com.zhouyu.Tom.helloWorld())")
	@Before("aaa()")
	public void aopBefore( JoinPoint joinPoint){
		System.out.println("before----- -----"  +joinPoint);
	}

	@After("execution(* com.zhouyu.Tom.helloWorld())")
	public void aopAfter(JoinPoint joinPoint  ){
		System.out.println("after------- ------"+joinPoint );
	}

	@AfterReturning(pointcut = "aaa()",returning = "res")
	public void aopAfterReturning(JoinPoint joinPoint ,String res){
		System.out.println("afterReturning------- -------"+joinPoint  + "=========>>" + res);
	}


	@AfterThrowing("execution(* com.zhouyu.Tom.helloWorld())")
	public void aopAfterThrowing(JoinPoint joinPoint  ){
		System.out.println("afterThrowing------ -------"+joinPoint );
	}

	@Around("execution(* com.zhouyu.Tom.helloWorld())")
	public Object aopAround(  ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
		System.out.println("around-----1111111111-------" + proceedingJoinPoint);
		String proceed = (String) proceedingJoinPoint.proceed();
		System.out.println("around-------2222222222-----" + proceedingJoinPoint);
		return proceed;
	}

}
